import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/tabs_controller.dart';

class TabsView extends GetView<TabsController> {
  const TabsView({super.key});
  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
          bottomNavigationBar: BottomNavigationBar(
              fixedColor: Colors.red,
              type: BottomNavigationBarType.fixed,
              currentIndex: controller.currentIndex.value,
              onTap: (index) {
                controller.setCurrentIndex(index);
                controller.pagecontroller.jumpToPage(index);
              },
              items: const [
                BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
                BottomNavigationBarItem(
                    icon: Icon(Icons.category), label: '分类'),
                BottomNavigationBarItem(icon: Icon(Icons.search), label: '服务'),
                BottomNavigationBarItem(
                    icon: Icon(Icons.settings), label: '购物车'),
                BottomNavigationBarItem(icon: Icon(Icons.people), label: '用户'),
              ]),
          body: PageView(
            children: controller.pages,
            controller: controller.pagecontroller,
            onPageChanged: (index) {
              controller.setCurrentIndex(index);
            },
          ),
        ));
  }
}
